﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <!-- items panel -->
    <ItemsPanelTemplate x:Key="HorizontalWrapPanelTemplate">
        <WrapPanel Orientation="Horizontal"/>
    </ItemsPanelTemplate>

    <!-- control templates -->
    <!-- validation -->
    <ControlTemplate x:Key="ValidationErrorTemplate">
        <Border BorderBrush="Red" BorderThickness="1" CornerRadius="2">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                </Grid.RowDefinitions>
                <AdornedElementPlaceholder Grid.Row="0" Grid.ColumnSpan="2" />
                <Image Grid.Row="1" Grid.Column="1" Margin="-5 0 0 0"
                       Height="16" Width="16" VerticalAlignment="Center"
                   Source="../Images/Error.png"
                   RenderOptions.BitmapScalingMode="NearestNeighbor" >
                    <Image.ToolTip>
                        <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding /ErrorContent}" Style="{DynamicResource ErrorHintTextBlockStyle}" />
                    </Image.ToolTip>
                </Image>
            </Grid>
        </Border>
    </ControlTemplate>

    <!-- list box -->
    <!--   - default -->
    <Style x:Key="DefaultListBoxItemStyle" TargetType="ListBoxItem">
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="FontWeight" Value="Bold" />
            </Trigger>
        </Style.Triggers>
    </Style>
    <Style x:Key="DefaultListBoxStyle" TargetType="ListBox">
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource DefaultListBoxItemStyle}" />
    </Style>
    <Style TargetType="ListBox" BasedOn="{StaticResource DefaultListBoxStyle}" />
    <!--   - radiobutton -->
    <Style x:Key="RadioButtonListBoxItemStyle" TargetType="{x:Type ListBoxItem}" >
        <Setter Property="Margin" Value="5" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <RadioButton IsChecked="{TemplateBinding IsSelected}" 
                                     IsHitTestVisible="False" Focusable="False">
                            <ContentPresenter />
                        </RadioButton>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="RadioButtonListBoxStyle" TargetType="{x:Type ListBox}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="ItemContainerStyle" Value="{StaticResource RadioButtonListBoxItemStyle}" />
        <Setter Property="ItemsPanel" Value="{StaticResource HorizontalWrapPanelTemplate}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Control.Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBox}">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <ItemsPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- button -->
    <Style TargetType="Button" BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}"/>
    <Style x:Key="TestConnectionButtonStyle" TargetType="Button" BasedOn="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" >
        <Style.Setters>
            <Setter Property="HorizontalAlignment" Value="Center" />
            <Setter Property="VerticalAlignment" Value="Top" />
            <Setter Property="Command" Value="{Binding TestConnectionCommand}" />
            <Setter Property="Content">
                <Setter.Value>
                    <StackPanel Orientation="Horizontal">
                        <Image Source="../Images/CheckConnection.png" Height="16" Width="16" Margin="5 2" />
                        <TextBlock Margin="0 0 5 0" VerticalAlignment="Center"
                                   Text="test connection"/>
                    </StackPanel>
                </Setter.Value>
            </Setter>
        </Style.Setters>
    </Style>
    <!-- combobox -->
    <Style TargetType="ComboBox" BasedOn="{StaticResource {x:Static ToolBar.ComboBoxStyleKey}}"/>

    <!-- textblock -->
    <Style x:Key="SubTextBlockStyle" TargetType="TextBlock">
        <Setter Property="FontSize" Value="12" />
        <Setter Property="FontStyle" Value="Italic" />
        <Setter Property="Foreground" Value="SteelBlue" />
    </Style>
    <Style x:Key="ErrorHintTextBlockStyle" TargetType="TextBlock">
        <Setter Property="Foreground" Value="Red" />
        <Setter Property="FontStyle" Value="Italic" />
    </Style>

    <!-- textbox -->
    <Style x:Key="ValidatableTextBoxStyle" TargetType="TextBox">
        <Setter Property="Validation.ErrorTemplate" Value="{DynamicResource ValidationErrorTemplate}" />
    </Style>
    <Style x:Key="ReadOnlyTextBoxStyle" TargetType="TextBox">
        <Setter Property="IsReadOnly" Value="True" />
        <Setter Property="IsReadOnlyCaretVisible" Value="False" />
        <Setter Property="Background" Value="White" />
    </Style>
    <Style x:Key="ValidatableReadOnlyTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource ReadOnlyTextBoxStyle}">
        <Setter Property="Validation.ErrorTemplate" Value="{DynamicResource ValidationErrorTemplate}" />
    </Style>
    <Style x:Key="MultiLineTextBoxStyle" TargetType="TextBox">
        <Setter Property="AcceptsReturn" Value="True" />
        <Setter Property="TextWrapping" Value="Wrap" />
        <Setter Property="VerticalAlignment" Value="Top" />
    </Style>
    <Style x:Key="ValidatableMultiLineTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource MultiLineTextBoxStyle}">
        <Setter Property="Validation.ErrorTemplate" Value="{DynamicResource ValidationErrorTemplate}" />
    </Style>
    <Style x:Key="ReadOnlyMultiLineTextBoxStyle" TargetType="TextBox" BasedOn="{StaticResource ReadOnlyTextBoxStyle}">
        <Setter Property="AcceptsReturn" Value="True" />
        <Setter Property="TextWrapping" Value="Wrap" />
        <Setter Property="VerticalAlignment" Value="Top" />
    </Style>

    <!-- group item -->
    <Style TargetType="{x:Type GroupItem}">
        <Setter Property="Margin" Value="0"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GroupItem}">
                    <DockPanel >
                        <TextBlock DockPanel.Dock="Top" 
                                       Text="{Binding Name}"
                                       Style="{DynamicResource SubTextBlockStyle}" />
                        <ItemsPresenter Margin="5 1 2 1" />
                    </DockPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>




</ResourceDictionary>